package com.jw.qme.core.handler;

import cn.dev33.satoken.util.SaResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 全局异常处理
     * @param e
     * @return
     */
    @ExceptionHandler
    SaResult defaultExceptionHandler(Exception e){
        e.printStackTrace();
        if(e instanceof RuntimeException){
            return SaResult.error(e.getMessage());
        } else
            return SaResult.error("系统异常请联系管理员");
    }

}
